<?php
header("content-type:text/html;charset=utf8");
include_once ("/Classes/PHPExcel.php");
$excel = PHPExcel_IOFactory::load("test.xlsx");
$sheet = $excel->getActiveSheet();
$roes = $sheet ->getHighestRow();
$cols = $sheet->getHighestColumn();
for ($i = 2; $i<=$roes;$i++)
{
    for ($j='A';$j<=$cols;$j++)
    {
        $data[$i-2][] = $sheet->getCell($j.$i)->getValue();

    }
}
//print_r($data);die;
$pdo = new PDO("mysql:host=127.0.0.1;dbname=11-9;charset=utf8",'root','root');
foreach ($data as $k => $v)
{
    $name = $v[0];
    $time = $v[1];
    $num = $v[2];
    $class = $v[3];
    $sql = "insert into excel values ('','$name','$time','$num','$class')";
    $res = $pdo->exec($sql);
//    print_r($res);die;
}
if($res)
{
    echo "<script>alert('导入成功');location.href='show.php'</script>";
}else{
    echo "<script>alert('导入成功');</script>";
}
?>